#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
using namespace std;

class Complex
{
public:
	Complex()
		:m_real(0.0f), m_image(0.0f){}
	Complex(float real, float image)
		:m_real(real), m_image(image){}
	
	Complex operator+(Complex right)
	{
		return Complex(this->m_real + right.m_real, this->m_image + right.m_image);
	}
	friend ostream& operator<<(ostream& out, const Complex& right)
	{
		out << right.m_real;
		if (right.m_image > 0)
		{
			right.m_image == 1 ? (out << "+" << "i") 
				: (out << "+" << right.m_image << "i");
		}
		else
		{
			right.m_image == -1 ? (out << "-i")
				: (out << right.m_image << "i");
		}
		return out;
	}
	
private:
	float m_real;
	float m_image;
};


int main()
{
	Complex test1(1.5, 2.2);
	Complex test2(1.5, 2.2);
	operator<<(cout, test1 + test2);
	return 0;
}